package com.huanuo.internetofthings.service.impact.facade;

import org.springframework.stereotype.Service;
import org.unicorn.framework.base.base.AbstractService;
import org.unicorn.framework.core.ResponseDto;
import org.unicorn.framework.core.exception.PendingException;
import org.unicorn.framework.core.handler.HandlerAdapter;

import com.huanuo.internetofthings.dto.impact.ImpactDeviceStatisticsReqDto;
import com.huanuo.internetofthings.enums.ImpactDeviceStatisticsType;

@Service
public class ImpactDeviceStatisticsFacadeService extends AbstractService {

	/**
	 * 统计用户所在组按设备类型的汇总情况    返回 设备总数、在网总数情况
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> statisticsByDeviceType(String userIdentity) throws PendingException {
		 ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		 impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		 impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.DeviceType);
		 return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	}

	/**
	 *  统计用户所在组  设备总数，在网总数、设备运行总时长
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> statisticsByGroupNo(String userIdentity) throws PendingException {
		 ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		 impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		 impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.DeviceGroupNo);
		 return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	
	}

	/**
	 * 统计用户所在组  设备开工时长月度分布情况
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> startingTimeDistribution(String userIdentity) throws PendingException {
		ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.Month_StartingTimeDistribution);
		return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	
	}
	
	
	/**
	 * 统计设备开工时长环比增长率分布
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> startingTimeRingRateDistribution(String userIdentity) throws PendingException {
		ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.Month_StartingTimeRingRateDistribution);
		return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	
	}
	
	/**
	 * 统计设备开工时长环比增长率分布
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> startingTimeRingRatioDistribution(String userIdentity) throws PendingException {
		 ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		 impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		 impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.Month_StartingTimeRingRateDistribution);
		 return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	}
 
	/**
	 * 统计设备开工时长同比增长率分布
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> startingTimeYearOnYearRatioDistribution(String userIdentity) throws PendingException {
		 ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		 impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		 impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.Month_StartingTimeYearOnYearRateDistribution);
		 return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	}
	

	/**
	 *  统计设备开工率月度分布情况
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> commencementRateDistribution(String userIdentity) throws PendingException {
		 ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		 impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		 impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.Month_CommencementRateDistribution);
		 return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	}
	
	/**
	 * 统计设备开工率环比增长分布情况
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> commencementRingRateDistribution(String userIdentity) throws PendingException {
		 ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		 impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		 impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.Month_CommencementRingRateDistribution);
		 return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	}
	
	/**
	 * 统计设备开工率同比比增长分布情况
	 * 
	 * @param userIdentity
	 * @return
	 * @throws PendingException
	 */
	public ResponseDto<?> commencementYearOnYearRateDistribution(String userIdentity) throws PendingException {
		 ImpactDeviceStatisticsReqDto impactDeviceStatisticsReqDto=new ImpactDeviceStatisticsReqDto();
		 impactDeviceStatisticsReqDto.setUserIdentity(userIdentity);
		 impactDeviceStatisticsReqDto.setImpactDeviceStatisticsType(ImpactDeviceStatisticsType.Month_CommencementYearOnYearRateDistribution);
		 return  HandlerAdapter.getHandler(impactDeviceStatisticsReqDto).execute(impactDeviceStatisticsReqDto);
	}

}